// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: IED in town 
// -----------------------------------------------

private [
	"_iedtype",
	"_iedobjects",
	"_object",
	"_marker",
	"_position",
	"_buildings",
	"_max"
];

_position = _this select 0;

_iedobjects = wciedobjects;

_buildings = nearestObjects [_position, ["Building"], 300];
sleep 1;

_max = round (random wcwithied);

for "_x" from 1 to _max step 1 do {
	_position = position (_buildings call BIS_fnc_selectRandom);
	_position = _position findEmptyPosition [1, 10];

	if (count _position > 0) then {
		_iedtype = _iedobjects call BIS_fnc_selectRandom;
		_iedobjects = _iedobjects - [_iedtype];

		_object = _iedtype createVehicle _position;
		_object setPos _position;
		_object setDir (random 360);

		_marker = [format ["mrkied%1", wciedindex], 0.5, _position, "ColorRed", "ICON", "FDIAGONAL", "dot", 0, ("IED: " + (typeOf _object)), false] call WC_fnc_createmarkerlocal;
		wcambiantmarker = wcambiantmarker + [_marker];
		wciedindex = wciedindex + 1;
		wcgarbage = [_object] spawn WC_fnc_createied;

		wcobjecttodelete = wcobjecttodelete + [_object];
	};
};